 function deleteItem(_id) {
 	//alert('资金项：' + _id);
 	layer.confirm('确定删除该资金项么？', {
 		btn: ['确定','取消']
 	}, function() {
 		var formServerData = new Object();
 		formServerData.id = _id;
 		console.log(JSON.stringify(formServerData));
 		$.ajax({
 			url: '/api/capital/item?id=' + _id,
 			cache: false,
 			data: JSON.stringify(formServerData),
 			dataType: 'json',
 			method: 'delete',
 			//headers : {'Content-type':'application/json;charset=utf-8'},
 			success: function(_response) {
 				if(_response.isSuccess) {
 					layer.msg('删除成功！', {icon: 1}, function() {
 						initPageCapitalItem();
 					});
 				} else {
 					layer.msg('删除失败！', {icon: 2});
 				}
 			},
 			error:function(xhr, textStatus) {
 				console.log(xhr);
 			}
 		});
 	});
 }

/*  
        * Unix时间戳转换成日期格式  FormatDateTime("1497232433000")  
        * @param UnixTime Unix时间戳  
        * @return yyyy-MM-dd HH:mm:ss  
        */ 
        function formatDateTime(unixTime) {  
 	//var a = UnixTime.replace("/Date(", "").replace(")/", "");  
 	var a = unixTime;
 	var date = new Date(parseInt(a));  
 	var y = date.getFullYear();  
 	var m = date.getMonth() + 1;  
 	m = m < 10 ? ('0' + m) : m;  
 	var d = date.getDate();  
 	d = d < 10 ? ('0' + d) : d;  
 	var h = date.getHours();  
 	h = h < 10 ? ('0' + h) : h;  
 	var minute = date.getMinutes();  
 	var second = date.getSeconds();  
 	minute = minute < 10 ? ('0' + minute) : minute;  
 	second = second < 10 ? ('0' + second) : second;  
 	return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;  
 }

 function initPageCapitalItem() {
 	// 获取行数
 	$.ajax({
 		url: '/api/capital/item',
 		data: 'pageSize=10&pageNumber=1',
 		dataType: 'json',
 		method: 'get',
 		success: function(_response) {
 			if(_response.isSuccess) {
 				var pager = new Pager();
 				initPager({
 					"_rowTotal": _response.pagination.total,
 					"_pageSize": 10,
 					"_mountDom": "#dtable-footer",
 					"_ajaxUrl": "/api/capital/item",
 					"rendorData": function(_obj) {
 						if(_obj.isSuccess) {
 							var dataGrid = '';
 							dataGrid += '<table class="default-table">';
 							dataGrid += '<thead>';
 							dataGrid += '<tr>';
 							dataGrid += '<th width="20%">创建日期</th>';
 							dataGrid += '<th width="20%">消费日期</th>';
 							dataGrid += '<th width="10%">金额</th>';
 							dataGrid += '<th width="10%">类型</th>';
 							dataGrid += '<th width="20%">备注</th>';
 							dataGrid += '<th width="20%">操作</th>';
 							dataGrid += '</tr>';
 							dataGrid += '</thead>';
 							if(_obj.pagination.total > 0) {
 								dataGrid += '<tbody>';
 								$.each(_obj.pagination.result, function(i, field) {
 									dataGrid += '<tr>';
 									dataGrid += '<td>' + formatDateTime(field.createTime) + '</td>';
 									dataGrid += '<td>' + formatDateTime(field.produceTime) + '</td>';
 									dataGrid += '<td>' + field.moneyAmount + '</td>';
 									if(field.opreaType == 'INCOME') {
 										dataGrid += '<td>收入</td>';
 									}
 									if(field.opreaType == 'EXPENDITURE') {
 										dataGrid += '<td>支出</td>';
 									}
 									dataGrid += '<td>' + field.remark + '</td>';
 									dataGrid += '<td>' + '<a href="javascript:void(0);">编辑</a> | <a href="javascript:deleteItem(' + field.id + ');">删除</a>' + '</td>';
 									dataGrid += '</tr>';
 								});
 								dataGrid += '</tbody>';
 							}
 							dataGrid += '</table>';
 						}
 						$('#dtable-content').html(dataGrid);
 					}
 				});
 			}
 		},
 		error:function(xhr, textStatus) {
 			console.log(xhr);
 		}
 	});
 }

 
 $(function() {
 	$('#add-capital-item').click(function() {
 		$.ajax({
 			url: '/html/capital/item/add-item.html',
 			cache: false,
 			success: function(data) {
 				var layer_index = layer.open({
 					type: 1,
 					title: '资金项 - 新增',
 					area: ['450px', '350px'],
 					content: '<div style="padding: 20px;">' + data + '</div>'
 				});
 				$('#layerIndex').val(layer_index);
 				laydate.render({
 					elem: '#produceDate',
 					theme: 'molv',
 					type: 'datetime',
 					format: 'yyyy-MM-dd HH:mm:ss'
 				});
 			},
 			error:function(xhr, textStatus) {
 				layer.msg('页面加载错误！');
 				console.log(xhr);
 			}
 		});
 	});

 	// 渲染日期组件
 	laydate.render({
 		elem: '#startDate',
 		theme: 'molv'
 	});

 	laydate.render({
 		elem: '#endDate',
 		theme: 'molv'
 	});

 	initPageCapitalItem();
 	//console.log(initPager('http://www.baidu.com/', '#dtable-footer', 500, 10, 35));
 });